package com.daoyin.ssph.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.daoyin.ssph.bean.Application;
import com.daoyin.ssph.service.AppService;

public class AppAction {
	private AppService app;
	
	private String id;
	public void setId(String id) {
		this.id = id;
	}
	public void setApp(AppService app) {
		this.app = app;
	}


	public String show(){
		HttpServletRequest request = ServletActionContext.getRequest();
		List<Application> list = app.query();
		
		request.setAttribute("show", list);

		return "success";
	
	}
	public String showDetails(){
		HttpServletRequest request = ServletActionContext.getRequest();
		Application application = app.query(Integer.parseInt(id));
		request.setAttribute("app", application);
		return "success";
	}
	
	public String delete(){
		app.delete(Integer.parseInt(id));
		return "success";
	}
}
